﻿@{
    Layout = null;
    ViewData["Title"] = "编辑产品";
    var NewType= ViewBag.NewType as List<BuyWithoutLoseMoney.Core.Models.NewsType>;
}
    
@model BuyWithoutLoseMoney.Core.Models.NewsType;
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <div>
        <div class="layui-card">
            <div class="layui-card-header">修改产品</div>
            <div class="layui-card-body">
                <form class="layui-form">
                    <input type="hidden" name="Id" value="@Model.Id" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类名字</label>
                        <div class="layui-input-block">
                            <input type="text" name="Name" value="@Model.Name" required lay-verify="required" placeholder="请输入产品标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                   
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="CreateTime" value="@Model.CreateTime.ToString()" id="ID-laydate-type-datetime1" placeholder="请选择上架时间">
                        </div>
                    </div>
                   
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="EditForm">修改</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="/js/vue.js"></script>
    <script src="/layui/layui.js"></script>
    <script>
        layui.use(["form", 'layer', 'laydate'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var laydate = layui.laydate
            laydate.render({
                elem: '#ID-laydate-type-datetime1',
                type: 'datetime'
            });
           
            //修改
            form.on('submit(EditForm)', function (data) {
                $.post("/admin/newtype/edit", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            parent.window.location.href = "/admin/newtype/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
</body>
</html>